package com.cssw.fyzb.wap.service;


import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.vo.GzAddPriceVo;
import com.cssw.fyzb.wap.model.vo.TurntableLogVo;
import com.cssw.fyzb.wap.model.vo.TurntableVo;
import com.ydn.appserver.MinaAppClient;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author YangYiQun
 */
@Service
public class TurntableService extends BaseService {

    private static final Logger logger = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private MinaAppClient busiClient;

    /**
     * 获取转盘信息
     *
     * @return
     */
    public AjaxData getTurnableInfo(Long userId) {
        Request request = new Request("GetTurnableInfo");
        request.setParameter("userId", userId);
        Response response = busiClient.send(request);

        return convertData(response);
    }


    /**
     * 获取转盘礼物配置
     *
     * @return
     */
    public AjaxPage<TurntableVo> getTurntable() {
        Request request = new Request("GetTurntable");
        Response response = busiClient.send(request);
        return convertPage(response, TurntableVo.class);
    }

    /**
     * 转盘抽奖
     *
     * @return
     */
    public AjaxData turn(Long userId) {
        Request request = new Request("Turn");
        request.setParameter("userId", userId);
        Response response = busiClient.send(request);
        return convertData(response);
    }


    /**
     * 获取抽奖记录
     *
     * @return
     */
    public AjaxPage<TurntableLogVo> getTurntableLog(Long userId) {
        Request request = new Request("GetTurntableLog");
        request.setParameter("userId", userId);
        Response response = busiClient.send(request);
        return convertPage(response, TurntableLogVo.class);
    }


    /**
     * 增值记录
     *
     * @return
     */
    public AjaxPage<GzAddPriceVo> getGzAddPrice(Long userId) {
        Request request = new Request("GetGzAddPrice");
        request.setParameter("userId", userId);
        Response response = busiClient.send(request);
        return convertPage(response, GzAddPriceVo.class);
    }
}

